package com.can.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.ibatis.type.Alias;

/**
 * javaBean
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("tbl_employee")
@Alias("employee")
//这里用引用类型是因为 引用类型可以为null，而基本类型都会有默认值这样框架不好判断.
public class Employee {

    //@TableId是主键注解
    //value:对应表中字段名,当属性名和表的列名不一致就要改为一致
    //type:配置主键的生成策略,IdType.AUTO表示数据库自增,UUID生成32位字符串，NONE无状态，INPUT自行输入，具体源码可以点进去看
    @TableId(value = "id",type = IdType.AUTO)
    private Long id;
    //@TableField非主键
    //value属性，如果属性名与数据库字段名不一致就要改为一致
    //属性exist = false 是否数据库字段，改为false代表忽略该属性,表示该属性与数据字段没有关联
    @TableField(value = "last_name")
    private String lastName;
    private String email;
    private Integer gender;
    private Integer age;

    @TableField(exist = false)
    private int abc;

    //手动生成的构造器用来测试添加方法
    public Employee(String lastName, String email, Integer gender, Integer age) {
        this.lastName = lastName;
        this.email = email;
        this.gender = gender;
        this.age = age;
    }
}
